using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-01-06
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 商品图片关联表
    /// </summary>
    [Verify]
    [Route("order/Corecmsbillaftersalesimages")]
    public class CorecmsbillaftersalesimagesController : BaseController
    {
        /// <summary>
        /// 商品图片关联表接口
        /// </summary>
        private readonly ICorecmsbillaftersalesimagesService _CorecmsbillaftersalesimagesService;

        public CorecmsbillaftersalesimagesController(ICorecmsbillaftersalesimagesService CorecmsbillaftersalesimagesService)
        {
            _CorecmsbillaftersalesimagesService = CorecmsbillaftersalesimagesService;
        }

        /// <summary>
        /// 查询商品图片关联表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsbillaftersalesimages:list")]
        public IActionResult QueryCorecmsbillaftersalesimages([FromQuery] CorecmsbillaftersalesimagesQueryDto parm)
        {
            var response = _CorecmsbillaftersalesimagesService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询商品图片关联表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmsbillaftersalesimages:query")]
        public IActionResult GetCorecmsbillaftersalesimages(string Id)
        {
            var response = _CorecmsbillaftersalesimagesService.GetInfo(Id);
            
            var info = response.Adapt<CorecmsbillaftersalesimagesDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加商品图片关联表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsbillaftersalesimages:add")]
        [Log(Title = "商品图片关联表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsbillaftersalesimages([FromBody] CorecmsbillaftersalesimagesDto parm)
        {
            var modal = parm.Adapt<Corecmsbillaftersalesimages>().ToCreate(HttpContext);

            var response = _CorecmsbillaftersalesimagesService.AddCorecmsbillaftersalesimages(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新商品图片关联表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsbillaftersalesimages:edit")]
        [Log(Title = "商品图片关联表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsbillaftersalesimages([FromBody] CorecmsbillaftersalesimagesDto parm)
        {
            var modal = parm.Adapt<Corecmsbillaftersalesimages>().ToUpdate(HttpContext);
            var response = _CorecmsbillaftersalesimagesService.UpdateCorecmsbillaftersalesimages(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除商品图片关联表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsbillaftersalesimages:delete")]
        [Log(Title = "商品图片关联表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsbillaftersalesimages([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmsbillaftersalesimagesService.Delete(idArr));
        }

    }
}